home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 3565-4.665 / dmg-4437 / packed.12 / custom4 / custom4
Text File  |  1987-04-21  |  7KB  |  150 lines

  1.                            Customising Stos
  2.                            ~~~~~~~~~~~~~~~~
  3.                    Part 4: Ditching The Fileselector
  4.                  or 'Once more into the breach..' (?)
  5.  
  6. The fileselector in STOS. Eh? What a nasty bit of code that is. I
  7. personally hate the damn thing, there it sits all smug listing my files
  8. and not letting me do the things I want, like entering *.* as a file
  9. name!! And have you aver noticed that if you have more than 8 drives
  10. connected that the STOS fileselector won't recognise the 9th and over.
  11.  
  12. Personal opinions aside, the STOS fileselector is a dead give away. If
  13. you need to communicate with the disk through this then everyone knows
  14. what language you've been using. Besides it tends to confuse people
  15. when instead of a nice familiar - if cumbersome - GEM fileselector,
  16. they get STOSs variation on the theme.
  17.  
  18. Over the next couple of articles were are going to code our own, can
  19. you contain your excitement. I have decided to do it in a cuple of
  20. steps because the article would stupidly long otherwise. In this first
  21. part we're going to get the 'bones' of the selector working.
  22.  
  23. The routine DISKSCAN.BAS if fully REMmed so you should be able to find
  24. your way around it quite easily, so I'll just cover the not so obvious
  25. points.
  26.  
  27. The program is basically a subroutine, with a bit added so you can see
  28. whats happening. The actual subroutine starts from line 300. Line 160
  29. (dim F_block$(300)) MUST be set up before you call the subroutine. This
  30. variable array hold the file information block.
  31.  
  32. STOS automatically generates a 45 character block which contains far
  33. more information than we will normally need, so we'll get rid of the
  34. uneeded parts i.e time,date and type. I will return to this later.
  35.  
  36. The first section reads in all the files that satisfy the mask setting.
  37.  
  38. 350 N_FILES=0           This is a counter for the number of files that
  39.                         match our search mask. On return this will hold
  40.                         the number of items that were found matching
  41.                         the search mask.
  42.  
  43. 355 FSELERR=0           An error flag. When you return from the routine
  44.                         you can check this to find out if an error has
  45.                         occurred. In this instance we are using it to
  46.                         check for an excess number of files in a
  47.                         directory. GemDos only allows about 150 or so
  48.                         files in a directory, but desktop programs like
  49.                         Neodesk allow any number you want up to 999.
  50.                         I've set the limit to 300 which is usually
  51.                         adequte for most circumstances.
  52.  
  53. 360 FSELTMP$=dir first$("*.*",-1)
  54.  
  55. The search mask "*.*" can be replaced with a variable holding the mask
  56. that you actually require. The -1 represents the type of file that will
  57. be listed. It is best to set it to list all file types and mask out
  58. what we don't need.
  59.  
  60. 390 if left$(FSELTMP$,1)="." then 460
  61.  
  62. The above line dumps file blocks that have '.' at the beginning.
  63. Because we have used -1 as the type flag STOS will return 'parent' and
  64. 'folder identifier' names as '.' and '..' so we have to mask these out.
  65. Keeping them would result in confusion to the user.
  66.  
  67. 420 FSELADD$=" " : if val(right$(FSELTMP$,3))=16 then FSELADD$=chr$(1)
  68.  
  69. This line needs a bit of explanation. FSELADD$ usually holds a space,
  70. but if the file type is a folder we will want to treat that differently
  71. from normal files. So we identify it with chr$(1). Chr$(1) is used so
  72. that during sort, we can put the folders at the top of the file
  73. listing. chr$(1) comes before everything except a null string which is
  74. chr$(0). You can't use chr$(0) to put the folders at the top because
  75. chr$(0) also means end of string.  If we were wanting an unsorted list
  76. - say to see what order AUTO files will run - then we would skip this
  77. sorting section. A simple flag and an if..then statement would suffice.
  78.  
  79. 510 sort F_BLOCK$(300) :this is where the CHR$(1) comes in.
  80.                         it's less than everything! so it comes first.
  81.  
  82. 550 for FSELT=0 to 300
  83.     : F_BLOCK$(FSELT)=mid$(F_BLOCK$(FSELT),2)
  84.   : next FSELT
  85.  
  86. Now that the array has been sorted we strip out the chr$(1) and space
  87. that we put in for sorting purposes.
  88.  
  89. Line 590- 610 simply got through the list in order to find the first
  90. entry that is not a null string. This is needed because SORT put the
  91. null strings first (which is daft) If we returned from the subroutine
  92. at this point then we would have an array filled with empty strings up
  93. until 300 - N_FILES down!
  94.  
  95. 590 for FSELT=0 to 300
  96. 600 if F_BLOCK$(FSELT)<>"" then SFSELT_FILE=FSELT : FSELT=300
  97. 610 next FSELT
  98.  
  99. Now that SFELT_FILE points to the first filled entry we have to move
  100. the information up from this point to start at position zero. This is
  101. again a simple loop.
  102.  
  103. 650 COUNFSELT=0         This is a secondary counter which starts at
  104.                         zero and will end up equalling N_FILES
  105.  
  106. 660 for FSELT=SFSELT_FILE to 300
  107.  
  108. Set up a loop to count from SFELT_FILE to the end of the array. All our
  109. file names are below SFSELT_FILE.
  110.  
  111. 670 F_BLOCK$(COUNFSELT)=F_BLOCK$(FSELT) : inc COUNFSELT
  112.  
  113. Move the the block up to the start+COUNFSELT
  114.  
  115. 680 next FSELT
  116.  
  117.  
  118. Thats it. All we have to do now is create a block definition that we
  119. will find useful. In this case we will get rid of the time,date and
  120. type of file it is. Of course because we are getting rid of the file
  121. type marker we will have to replace it with comething. In the GEM
  122. fileselector the folders have a little symbol beside the file name. We
  123. can look at this marker inside the fileselector subroutine to decide
  124. what action is needed. In this case I've used the copyright symbol but
  125. you can create any symbol using the font accessory in STOS.
  126.  
  127. 720 for FSELT=0 to N_FILES
  128.  
  129. The next line simply adds either a space (for a normal file) or
  130. chr$(189) (for a folder) and cuts off the information we don't need.
  131.  
  132. 730 if val(right$(F_BLOCK$(FSELT),3))=16 then
  133.         F_BLOCK$(FSELT)=chr$(189)+left$(F_BLOCK$(FSELT),22)
  134.         else F_BLOCK$(FSELT)=" "+left$(F_BLOCK$(FSELT),22)
  135.  
  136. 740 next FSELT
  137. 750 return
  138.  
  139. Well that's it for just now. Next time we will be working on an
  140. interface for the user. In the mean time why don't you have a go at
  141. making an interface. If you make a good one why not send it to Stosser,
  142. other user might find it handy!
  143.  
  144.  
  145.                                    Auld Bastid 1993
  146.  
  147.  
  148.  
  149.  
  150.